﻿/**
 *------------------------------------------
 * @file QueryRenderer.cpp
 * Rodeo Game Engine source file
 * Copyright(c) 2010-2011 Marcin Goryca
 *------------------------------------------
 */
#include "renderer\gl\queryrenderer.h"

using namespace std;

namespace rodeorenderer
{
void QueryRenderer::run()
{
//Simple Exception Handling
    try
    {
        gl21supported_ = ::atof((const char*)glGetString(GL_VERSION)) >= 2.1;
        if(!gl21supported_)
            throw rodeocore::RendererException("Sorry, your GPU doesn't support OpenGL 2.1");
        
        gl31supported_ = ::atof((const char*)glGetString(GL_VERSION)) >= 3.1;
        if(!gl31supported_)
            throw rodeocore::RendererException("Sorry, your GPU doesn't support OpenGL 3.1");
    
        gl32supported_ = ::atof((const char*)glGetString(GL_VERSION)) >= 3.2; 
        if(!gl32supported_)
            throw rodeocore::RendererException("Sorry, your GPU doesn't support OpenGL 3.2");
        
        gl33supported_ = ::atof((const char*)glGetString(GL_VERSION)) >= 3.3;
        if(!gl33supported_)
            throw rodeocore::RendererException("Sorry, your GPU doesn't support OpenGL 3.3");

        gl41supported_ = ::atof((const char*)glGetString(GL_VERSION)) >= 4.1;
        if(!gl41supported_)
            throw rodeocore::RendererException("Sorry, your GPU doesn't support OpenGL 4.1");
    }
    catch(rodeocore::RendererException& renderer_exception)
    {
        //Exception handling code 
        renderer_exception.getExceptionString();
    }
}


string QueryRenderer::print(string s)const
{	
	return s;
}

/**
 *
 */

bool QueryRenderer::reset()
{
	glvendor_ = 0;
	glrenderer_ = 0;
	glversion_ = 0;
	return true;
}

/**
 *
 */

void QueryRenderer::checkMultisampling()
{
    int result=0;
    glGetIntegerv(GL_SAMPLE_BUFFERS, &result);
    
    if(result == 1)
    {
        //Print appropriate message
    }
    else
    {
        //Throw an exception
    }
}
}